package com.tudouji.project.mt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.mt.domain.MtShop;
import com.tudouji.project.mt.service.IMtShopService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 美团店铺Controller
 * 
 * @author tudouji
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/mt/shop")
public class MtShopController extends BaseController
{
    @Autowired
    private IMtShopService mtShopService;

    /**
     * 查询美团店铺列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtShop mtShop)
    {
        startPage();
        List<MtShop> list = mtShopService.selectMtShopList(mtShop);
        return getDataTable(list);
    }

    /**
     * 导出美团店铺列表
     */
    @PreAuthorize("@ss.hasPermi('mt:shop:export')")
    @Log(title = "美团店铺", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MtShop mtShop)
    {
        List<MtShop> list = mtShopService.selectMtShopList(mtShop);
        ExcelUtil<MtShop> util = new ExcelUtil<MtShop>(MtShop.class);
        return util.exportExcel(list, "shop");
    }

    /**
     * 获取美团店铺详细信息
     */
    @PreAuthorize("@ss.hasPermi('mt:shop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mtShopService.selectMtShopById(id));
    }

    /**
     * 新增美团店铺
     */
    @PreAuthorize("@ss.hasPermi('mt:shop:add')")
    @Log(title = "美团店铺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtShop mtShop)
    {
        return toAjax(mtShopService.insertMtShop(mtShop));
    }

    /**
     * 修改美团店铺
     */
    @PreAuthorize("@ss.hasPermi('mt:shop:edit')")
    @Log(title = "美团店铺", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtShop mtShop)
    {
        return toAjax(mtShopService.updateMtShop(mtShop));
    }

    /**
     * 删除美团店铺
     */
    @PreAuthorize("@ss.hasPermi('mt:shop:remove')")
    @Log(title = "美团店铺", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtShopService.deleteMtShopByIds(ids));
    }


    /**
     * 美团拉取
     */
    @PostMapping("/pull")
    public AjaxResult pull(@RequestBody MtShop mtShop)
    {
        return mtShopService.pull(mtShop);
    }


}
